/****************************************************
    文件：GameRoot.cs
	作者：kk
    邮箱: 627515104@qq.com
    日期：2020/8/26 14:46:11
	功能：Nothing
*****************************************************/

using UnityEngine;

public class GameRoot : MonoBehaviour
{
    public static GameRoot Instance = null;
    public LoadingWnd LoadingWnd;
    public DynamicWnd DynamicWnd;

    private void Awake()
    {
        Instance = this;
    }
    

    private void Start()
    {
        DontDestroyOnLoad(this);
        Debug.Log("Game Start...");
        ClearUIRoot();
        Init();
    }

    private void ClearUIRoot()
    {
        Transform canvas = transform.Find("Canvas");
        for (int i = 0; i < canvas.childCount; i++)
        {
            canvas.GetChild(i).gameObject.SetActive(false);
        }
        DynamicWnd.SetWndState(true);
    }


    public void Init()
    {
        //服务模块初始化
        ResSvc res = GetComponent<ResSvc>();
        res.InitSvc();

        AudioSvc audio = GetComponent<AudioSvc>();
        audio.InitSvc();
        //业务模块初始化
        LoginSys login = GetComponent<LoginSys>();
        login.InitSys();

        //进入登陆场景
        login.EnterLogin();
    }

    public static void AddTips(string tips)
    {
        Instance.DynamicWnd.AddTips(tips);
    }
}